echo --------------------------------------------
echo INSTALL RAC Service
echo --------------------------------------------

mkdir /etc/rac
mkdir /etc/rac/bin
mkdir /etc/rac/conf
mkdir /etc/rac/log
mkdir /etc/rac/auth

gcc -lssl -time -fstack-protector-all log.c rac-server.c -o rac-server
gcc -lssl -time -fstack-protector-all attrib.c init.c crypt_pwd_gestion.c ban_ip.c port.c rac-gestion.c -o rac-gestion

cp ./rac-server /bin/
cp ./rac-server /etc/rac/bin/

cp ./rac-gestion /bin/
cp ./rac-gestion /etc/rac/bin/

echo 5869 >> /etc/rac/conf/port.conf
echo 21232f297a57a5a743894a0e4a801fc3 >> /etc/rac/conf/pwd.conf

> /etc/rac/auth/ip.conf
> /etc/rac/log/log-commandes.log

groupadd -g 503 racgroup
useradd -d /etc/rac/chroot/ -g 503 -u 502 racuser -s /bin/sh

echo 502 >> /etc/rac/conf/id.conf

chmod 700 /etc/rac/conf/*
chmod 700 /etc/rac/auth/*
chmod 700 /etc/rac/log/*

chown racuser -R /etc/rac/
chgrp racgroup -R /etc/rac/

echo --------------------------------------------
echo RAC server v5.5.10 install complete.
echo --------------------------------------------
